package org.melanesia.converters.jdbc;

import java.sql.CallableStatement;

import org.melanesia.converters.JavaToJdbcConverter;

/**
 * A simple pass-thru converter that does not convert values, only passes it
 * thru returning specified JDBC Type. This should be used for simple types like
 * String, Integer, Double etc. that can be successfully handled by JDBC without
 * conversion.
 * 
 * @author marcin.kielar
 */
public final class PassThruJdbcConverter implements JavaToJdbcConverter {

    /** Holder for the jdbc type that this converter produces. */
    private final int jdbcType;

    /**
     * Constructs a {@link PassThruJdbcConverter}.
     * 
     * @param jdbcType
     *            jdbc type produced by this converter
     */
    public PassThruJdbcConverter(final int jdbcType) {
        this.jdbcType = jdbcType;
    }

    @Override
    public Object convert(final Object value, final CallableStatement stmt, final String parameterName) {
        return value;
    }

    @Override
    public int getJdbcType() {
        return jdbcType;
    }
}
